<?php

namespace App\Libraries\AppSocialite\Providers;

use App\Libraries\AppSocialite\Contracts\Provider as ProviderContract;
use Illuminate\Http\Request;

abstract class AbstractProvider implements ProviderContract
{
    /**
     * The HTTP request instance.
     *
     * @var \Illuminate\Http\Request
     */
    protected $request;

    /**
     * The provider config.
     *
     * @var array
     */
    protected $config;

    /**
     * Create a new provider instance.
     *
     * @param   Request  $request
     * @param   array    $config
     *
     * @return  void
     */
    public function __construct(Request $request, array $config)
    {
        $this->request = $request;
        $this->config = $config;
    }

    /**
     * Get the raw user for the given access token.
     *
     * @param  string  $token
     * @return array
     */
    abstract protected function getUserByToken($token);

    /**
     * Map the raw user array to a Socialite User instance.
     *
     * @param  array  $user
     * @return \Laravel\Socialite\Two\User
     */
    abstract protected function mapUserToObject(array $user);
}
